<template>
  <div class="dashboard-container">
    <!-- 这是首页header -->
    <el-card
      class="headcard"
      type="flex"
      style="height = 7.5rem"
      shadow="hover"
    >
      <div class="all">
        <div class="headImg">
          <!-- 处理默认图片 -->
          <img
            src="https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png"
          />
        </div>
        <div class="headInfoTip">
          <p class="firstChild">{{getTimeState()}}，{{ name }}，祝你开心每一天！</p>
          <!-- 辅助函数 -->
          <p class="lastChild">HI，{{ name }}，您已经入职{{ date }}天了</p>
          <!-- 最原始的方式 -->
          <!-- <p class="lastChild">{{ name }} | {{ $store.state.user.userInfo.company }} - {{ $store.state.user.userInfo.departmentName }} </p> -->
        </div>

        <div class="right-content">
          <!-- <div class="right">
            <span class="number">代办</span>
            <span class="content">2/8</span>
          </div>
          <div class="middle">
            <span class="number">会议</span>
            <span class="content">2</span>
             
          </div>
          <div class="left">
            <span class="number">团队</span>
            <span class="content">300</span>
          </div> -->
          <div class="r-one">
            <svg class="icon">
              <use xlink:href="#icon-task"></use>
            </svg>
            <div class="desk">
              <span class="content">代办</span>
              <span class="number">2/8</span>
            </div>
          </div>
          <div class="r-two">
             <svg class="icon">
              <use xlink:href="#icon-huiyishi"></use>
            </svg>
            <div class="metting">
              <span class="content">会议</span>
              <span class="number">2</span>
            </div>
          </div>
          <div class="r-three">
             <svg class="icon">
              <use xlink:href="#icon-tuandui"></use>
            </svg>
            <div class="team">
              <span class="content">团队</span>
              <span class="number">300</span>
            </div>
          </div>
        </div>
      </div>
    </el-card>
  </div>
</template>
<script>
import {loginByUsername} from '@/api/user'
export default {
  name: "header",
  data() {
    return {
      weldata: [],
      name: {},
      id:[],
tenantId:[],
date: 10,
title:""
    };
  },
  components: {},
  created() {

this.isday()
// this.loginByUsername()

  },
  methods:{
    //获取用户接口的请求
 async loginByUsername(){
const {username, tenantId} = await loginByUsername(tenantId);
  this.name =username
  this.tenantId= tenantId
},
//获取时间用来判断当前是上午还是下午


getTimeState(){
    // 获取当前时间
    let timeNow = new Date();
    // 获取当前小时
    let hours = timeNow.getHours();
    // 设置默认文字
    let state= ``;
    // 判断当前时间段
    if (hours >= 0 && hours <= 10) {
        state = `早上好!`;
    } else if (hours > 10 && hours <= 14) {
        state= `中午好!`;
    } else if (hours > 14 && hours <= 18) {
        state= `下午好!`;
    } else if (hours > 18 && hours <= 24) {
        state= `晚上好!`;
    }
    return state;
},



  },
};
</script>

<style scoped>
.headImg img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}
.headImg {
  float: left;
  width: 6.25rem;
  height: 6.25rem;
  border-radius: 50%;
  background: #999;
}
.right-content {
  display: flex;
  margin-right: 28 px;

  height: 6.25rem;
  width: 25rem;
}
.number {
  font-size: 2rem;
}
.all {
  display: flex;
  flex-flow: row;
}
.headInfoTip {
  margin-left: 1.875rem;
  flex: 1;
}
.firstChild {
  font-size: 1.125rem;
  line-height: 1.75rem;
  font-weight: 600;
}
.right-content {
  display: flex;
  justify-content: space-between;
  width: 43rem;
}
.r-one {
  background-color: #8a70b4;
}
.r-two {
  background-color: #60a2e3;
}
.r-three {
  background-color: #8fc99a;
}
.r-one,
.r-two,
.r-three {
  display: flex;
  text-align: center;
  flex-direction: row;
  justify-content: space-around;
  height: 5.825rem;
  width: 12.85rem;
  border-radius: 0.9375rem;
  font-size: 18px;
  font-weight: 500;
}
.icon  {
width: 2.5rem;
}
.desk,.metting,.team{
display: flex;
flex-direction: column;
justify-content: center;
margin-left: -4.0625rem;
}
</style>
